/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 救援代理人服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const rescueAgentApi = urls.rescueAgent

function listAllAgent(param, success, complete) {
  postRequest(rescueAgentApi.listAllAgent, {}, param, success, complete)
}

function listAllAgentDriver(id, success, complete) {
  postRequest(rescueAgentApi.listAllAgentDriver + id, {}, {}, success, complete)
}

function list(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.list + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listAgent(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.listAgent + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listServiceProdiverAgent(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.listServiceProdiverAgent + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listAuditAgent(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.listAuditAgent + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listProdiverAgent(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.listProdiverAgent + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listAgentPayable(param, page, pageSize, success, complete) {
  postRequest(rescueAgentApi.listAgentPayable + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function auditRescueAgent(id, param, success, complete) {
  postRequest(rescueAgentApi.auditRescueAgent + id, {}, param, success, complete)
}

function saveProdiverAgent(param, success, complete) {
  postRequest(rescueAgentApi.saveProdiverAgent, {}, param, success, complete)
}

function updateProdiverAgent(param, success, complete) {
  postRequest(rescueAgentApi.updateProdiverAgent, {}, param, success, complete)
}


function getRescueAgentById(id, success, complete) {
  getRequest(rescueAgentApi.getRescueAgentById + id, {}, success, complete)
}

function removeRescueAgent(ids, success, complete) {
  postRequest(rescueAgentApi.removeRescueAgent, {}, ids, success, complete)
}

function unfreezeCommission(param, success, complete) {
  postRequest(rescueAgentApi.unfreezeCommission, {}, param, success, complete)
}

function adjustmentCommission(param, success, complete) {
  postRequest(rescueAgentApi.adjustmentCommission, {}, param, success, complete)
}

function adjustmentIntegral(param, success, complete) {
  postRequest(rescueAgentApi.adjustmentIntegral, {}, param, success, complete)
}

function countAuditingRescueCompanyAgent(success, complete) {
  getRequest(rescueAgentApi.countAuditingRescueCompanyAgent, {}, success, complete)
}


function deleteSingleRescueAgent(id, success, complete) {
  let ids = []
  ids.push(id)
  removeRescueAgent(ids, success, complete)
}

function removeProdiverAgent(ids, success, complete) {
  postRequest(rescueAgentApi.removeProdiverAgent, {}, ids, success, complete)
}

function deleteSingleRescueProvinceAgent(id, success, complete) {
  let ids = []
  ids.push(id)
  removeProdiverAgent(ids, success, complete)
}

function getInfoWithOffLine(success, complete) {
  getRequest(rescueAgentApi.getInfoWithOffLine, {},success, complete)
}

function changeShowPromotion(success, complete) {
  postRequest(rescueAgentApi.changeShowPromotion, {},success, complete)
}

function getMyOffLine(success, complete) {
  getRequest(rescueAgentApi.getMyOffLine, {},success, complete)
}

export default {
  listAllAgentDriver,
  countAuditingRescueCompanyAgent,
  listAllAgent,
  listAgent,
  listAuditAgent,
  listProdiverAgent,
  listAgentPayable,
  auditRescueAgent,
  getRescueAgentById,
  removeRescueAgent,
  deleteSingleRescueAgent,
  saveProdiverAgent,
  updateProdiverAgent,
  removeProdiverAgent,
  deleteSingleRescueProvinceAgent,
  unfreezeCommission,
  adjustmentCommission,
  adjustmentIntegral,
  listServiceProdiverAgent,
  list,
  getInfoWithOffLine,
  changeShowPromotion,
  getMyOffLine
}
